# 加互斥锁
from threading import Thread,Lock

zero=0
lock=Lock()

def foo():
    global zero
    for i in range(10**5):
        with lock:
            zero+=1
            zero-=1

if __name__=="__main__":
    thread_arr=[]
    for i in range(2):
        t=Thread(target=foo)
        thread_arr.append(t)
        t.start()
    for t in thread_arr:
        t.join()

    print(zero)
    print("done")
# 0
# done
